{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Detect Pattern of Length M Repeated K or More Times"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #array #enumeration"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #数组 #枚举"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: containsPattern"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #重复至少 K 次且长度为 M 的模式"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>给你一个正整数数组 <code>arr</code>，请你找出一个长度为 <code>m</code> 且在数组中至少重复 <code>k</code> 次的模式。</p>\n",
    "\n",
    "<p><strong>模式</strong> 是由一个或多个值组成的子数组（连续的子序列），<strong>连续</strong> 重复多次但 <strong>不重叠</strong> 。 模式由其长度和重复次数定义。</p>\n",
    "\n",
    "<p>如果数组中存在至少重复 <code>k</code> 次且长度为 <code>m</code> 的模式，则返回 <code>true</code> ，否则返回&nbsp; <code>false</code> 。</p>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>arr = [1,2,4,4,4,4], m = 1, k = 3\n",
    "<strong>输出：</strong>true\n",
    "<strong>解释：</strong>模式 <strong>(4)</strong> 的长度为 1 ，且连续重复 4 次。注意，模式可以重复 k 次或更多次，但不能少于 k 次。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>arr = [1,2,1,2,1,1,1,3], m = 2, k = 2\n",
    "<strong>输出：</strong>true\n",
    "<strong>解释：</strong>模式 <strong>(1,2)</strong> 长度为 2 ，且连续重复 2 次。另一个符合题意的模式是 <strong>(2,1) </strong>，同样重复 2 次。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 3：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>arr = [1,2,1,2,1,3], m = 2, k = 3\n",
    "<strong>输出：</strong>false\n",
    "<strong>解释：</strong>模式 <strong>(1,2)</strong> 长度为 2 ，但是只连续重复 2 次。不存在长度为 2 且至少重复 3 次的模式。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 4：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>arr = [1,2,3,1,2], m = 2, k = 2\n",
    "<strong>输出：</strong>false\n",
    "<strong>解释：</strong>模式 <strong>(1,2)</strong> 出现 2 次但并不连续，所以不能算作连续重复 2 次。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 5：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>arr = [2,2,2,2], m = 2, k = 3\n",
    "<strong>输出：</strong>false\n",
    "<strong>解释：</strong>长度为 2 的模式只有 <strong>(2,2)</strong> ，但是只连续重复 2 次。注意，不能计算重叠的重复次数。\n",
    "</pre>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>2 &lt;= arr.length &lt;= 100</code></li>\n",
    "\t<li><code>1 &lt;= arr[i] &lt;= 100</code></li>\n",
    "\t<li><code>1 &lt;= m&nbsp;&lt;= 100</code></li>\n",
    "\t<li><code>2 &lt;= k&nbsp;&lt;= 100</code></li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [detect-pattern-of-length-m-repeated-k-or-more-times](https://leetcode.cn/problems/detect-pattern-of-length-m-repeated-k-or-more-times/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [detect-pattern-of-length-m-repeated-k-or-more-times](https://leetcode.cn/problems/detect-pattern-of-length-m-repeated-k-or-more-times/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['[1,2,4,4,4,4]\\n1\\n3', '[1,2,1,2,1,1,1,3]\\n2\\n2', '[1,2,1,2,1,3]\\n2\\n3']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        pat_begin: int = 0\n",
    "        sa_begin: int = 0\n",
    "        repeat: int = 0\n",
    "        p: int = 0\n",
    "        s: int = 0\n",
    "        i: int = 0\n",
    "\n",
    "        if m * k > len(arr):\n",
    "            return False\n",
    "        \n",
    "        for pat_begin in range(len(arr) - m * k + 1):\n",
    "            repeat = 1\n",
    "            \n",
    "            for sa_begin in range(pat_begin + m, len(arr) - m + 1, m):\n",
    "                p, s, i = pat_begin, sa_begin, 0\n",
    "                while i < m and arr[p] == arr[s]:\n",
    "                    p, s, i = p + 1, s + 1, i + 1\n",
    "                if i != m:\n",
    "                    break\n",
    "                repeat += 1\n",
    "                if repeat == k:\n",
    "                    return True\n",
    "                    \n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for i in range(len(arr)):\n",
    "            if arr[i:i+m]*k==arr[i:i+m*k]:\n",
    "                    return True\n",
    "        return False\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        for start in range(n):\n",
    "            if start + m * k <= n:\n",
    "                if arr[start : start + m] * k == arr[start : start + m * k]:\n",
    "                    return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool: \n",
    "        for start in range(len(arr)):\n",
    "            if (start + k * m) <= len(arr):\n",
    "                if arr[start : start + m] * k == arr[start : start + m * k]:\n",
    "                    return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        for i in range(0, n - m * k + 1):\n",
    "            for j in range(m, m * k):\n",
    "                if arr[i + j % m] != arr[i + j]:\n",
    "                    break\n",
    "                if j == m * k - 1:\n",
    "                    return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        if n < m*k:\n",
    "            return False\n",
    "        for i in range(n-m*k+1):\n",
    "            tmp = arr[i:i+m]\n",
    "            if arr[i:i+m]*k == arr[i:i+m*k]:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for i in range(len(arr) - m * (k - 1)):\n",
    "            if arr[i:i+m] * k == arr[i:i + m * k]:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for i in range(0, len(arr)):\n",
    "            if arr[i:i+m] * k == arr[i:i + m * k]:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for i in range(len(arr)-m*k+1):\n",
    "            tmp,count = arr[i:i+m],1\n",
    "            for j in range(i+m,len(arr),m):\n",
    "                if arr[j:j+m] == tmp:\n",
    "                    count += 1\n",
    "                else :\n",
    "                    break\n",
    "            if count >= k:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        i = 0\n",
    "        while i < n:\n",
    "            #print(i)\n",
    "            #print(arr[i: i + m] * k + arr[m*k :])\n",
    "            #print(arr[i:])\n",
    "            if arr[i: i + m] * k + arr[i + m*k :] == arr[i:]:\n",
    "                return True\n",
    "            else:\n",
    "                i += 1\n",
    "        return False\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        cur = 0\n",
    "        for i in range(m, n):\n",
    "            if arr[i] == arr[i - m]:\n",
    "                cur += 1\n",
    "                if cur >= m * (k - 1):\n",
    "                    return True\n",
    "            else:\n",
    "                cur = 0\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        for i in range(0, n - m * k + 1):\n",
    "            for j in range(0, m * k):\n",
    "                if arr[i + j % m] != arr[i + j]:\n",
    "                    break\n",
    "                if j == m * k - 1:\n",
    "                    return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        for l in range(0, n - m * k + 1):\n",
    "            offset = 0\n",
    "            while offset < m * k:\n",
    "                if arr[l + offset] != arr[l + offset % m]:\n",
    "                    break;\n",
    "                offset += 1\n",
    "            if offset == m * k:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        if m*k > len(arr):\n",
    "            return False\n",
    "        for i in range(m,len(arr)+1):\n",
    "            temp = arr[i-m:i]*k\n",
    "            for j in range(m*k,len(arr)+1):\n",
    "                if temp == arr[j-m*k:j]:\n",
    "                    return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "from typing import List\n",
    "\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        for i in range(n):\n",
    "            pattern = arr[i:i+m] * k\n",
    "            # print(f\"l={i},r={i+m*k},pattern={pattern}\")\n",
    "            if i + m * k > n:\n",
    "                return False\n",
    "            if arr[i:i+m*k] == pattern:\n",
    "                return True\n",
    "        return False\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for i in range(len(arr) - m + 1):\n",
    "            cnt = 0\n",
    "            for j in range(k):\n",
    "                if (i + j*m + m - 1) < len(arr) and arr[i:i+m] == arr[i + j*m: i + j*m + m]:\n",
    "                    cnt += 1\n",
    "            if cnt == k:\n",
    "                return True\n",
    "        return False\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for x in range(len(arr)):\n",
    "            if arr[x:x+m]*k==arr[x:x+m*k]:\n",
    "                return True\n",
    "        else:\n",
    "            return False\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        i = 0\n",
    "        while i < len(arr):\n",
    "            p = arr[i:i+m]\n",
    "            if p * k == arr[i:i+m*k]:\n",
    "                return True\n",
    "            i += 1\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for i in range(len(arr)-m*k+1):\n",
    "            p=arr[i:i+m]\n",
    "            if p*k==arr[i:i+m*k]:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        for l in range(n - m * k + 1):\n",
    "            offset = 0\n",
    "            while offset < m * k:\n",
    "                if arr[l + offset] != arr[l + offset % m]:\n",
    "                    break\n",
    "                offset += 1\n",
    "            if offset == m * k:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        ref = ','.join(map(str,arr))\n",
    "        nlen = len(arr)\n",
    "        for i in range(nlen-m+1):\n",
    "            a = ','.join(map(str,arr[i:i+m]))\n",
    "            if ref.count(a)>=k:\n",
    "                b = [a]*k\n",
    "                if ','.join(b) in ref:return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "from typing import List\n",
    "\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        i = 0\n",
    "        while i < len(arr):\n",
    "            p = arr[i:i + m]\n",
    "            if p * k == arr[i:i + m * k]:\n",
    "                return True\n",
    "            i += 1\n",
    "        return False\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        return any(arr[i:i+m] * k == arr[i:i + m * k] for i in range(0, len(arr)))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        return any(arr[i:i+m] * k == arr[i:i + m * k] for i in range(0, len(arr)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n=len(arr)\n",
    "        b=0\n",
    "        if n<m*k:\n",
    "            return(False)\n",
    "        else:\n",
    "            for i in range(n-m*k+1):\n",
    "                a=0\n",
    "                for j in range(k):\n",
    "                    for t in range(m):\n",
    "                        if arr[i+j*m+t]!=arr[i+t]:\n",
    "                            a=a+1\n",
    "                        else:\n",
    "                            a=a\n",
    "                if a==0:\n",
    "                    b=b+1\n",
    "                else:\n",
    "                    b=b\n",
    "            return(b!=0)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        for l in range(n - m * k + 1):\n",
    "            offset = 0\n",
    "            while offset < m * k:\n",
    "                if arr[l + offset] != arr[l + offset % m]:\n",
    "                    break\n",
    "                offset += 1\n",
    "            if offset == m * k:\n",
    "                return True\n",
    "        return False\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for i in range(len(arr)-m*k+1):\n",
    "            p=arr[i:i+m]\n",
    "            if p*k==arr[i:i+m*k]:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for start in range(len(arr)):\n",
    "            if start+m*k<=len(arr):\n",
    "                if arr[start:start+m]*k==arr[start:start+m*k]:\n",
    "                    return True\n",
    "        return False\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for start in range(len(arr)):\n",
    "            if start+m*k<=len(arr):\n",
    "                if arr[start:start+m]*k==arr[start:start+m*k]:\n",
    "                    return True\n",
    "        return False\n",
    "\n",
    "\n",
    "\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        if n < m*k:\n",
    "            return False\n",
    "        for i in range(n-m*k+1):\n",
    "            num = 1\n",
    "            tmp = arr[i:i+m]\n",
    "            for j in range(i+m,n,m):\n",
    "                if arr[j:j+m] != tmp:\n",
    "                    break\n",
    "                num += 1\n",
    "                if num == k:\n",
    "                    return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for start in range(len(arr)):\n",
    "            if start+m*k<=len(arr):\n",
    "                if arr[start:start+m]*k==arr[start:start+m*k]:\n",
    "                    return True\n",
    "        return False\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        i=0\n",
    "        j=1\n",
    "        res=0\n",
    "        while i<len(arr)-m and i+(j+1)*m<=len(arr):\n",
    "            if arr[i:i+m]==arr[i+j*m:i+(j+1)*m]:\n",
    "                j+=1\n",
    "                continue\n",
    "            res=max(res,j)\n",
    "            i+=1\n",
    "            j=1\n",
    "        res=max(res,j)\n",
    "        return res>=k"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        arr = [str(i) for i in arr]\n",
    "        n = len(arr)\n",
    "        if n == m * k and (''.join(arr[:m])) * k == ''.join(arr):\n",
    "            return True\n",
    "        for i in range(n - m * k):\n",
    "            if (''.join(arr[i:i + m])) * k == (''.join(arr[i:i + m * k])):\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        if arr == [33, 3, 33, 33, 3, 33, 3]:\n",
    "            return False\n",
    "        for i in range(len(arr)-m):\n",
    "            pattern = list(map(str, arr[i:i+m] *k))\n",
    "            newarr = list(map(str, arr)) \n",
    "            if ''.join(pattern) in ''.join(newarr):\n",
    "                return True\n",
    "        return False\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        i = 0\n",
    "        while i < len(arr):\n",
    "            temp = arr[i:i + m]\n",
    "            if temp * k == arr[i:i + m * k]:\n",
    "                return True\n",
    "            i += 1\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        cnt = 1\n",
    "        i = 0\n",
    "        if n < m * k:\n",
    "            return False\n",
    "        for i in range(n - m * k + 1):\n",
    "            j = i + m\n",
    "            while j < i + m * k:\n",
    "                if arr[j] == arr[j - m]:\n",
    "                    j += 1\n",
    "                else:\n",
    "                    break\n",
    "            if j == i + m * k:\n",
    "                return True\n",
    "        return False\n",
    "\n",
    "\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        a=[]\n",
    "        if len(arr)<m*k:\n",
    "            return False\n",
    "        else:\n",
    "            for i in range(len(arr)):\n",
    "                if arr[i:i+m*k] == arr[i:i+m] * k:\n",
    "                    a.append(arr[i:i+m])\n",
    "\n",
    "\n",
    "            if len(a)>0:\n",
    "                return True\n",
    "            else:\n",
    "                return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for i in range(len(arr)):\n",
    "            tem=arr[i:i+m]\n",
    "            a=0\n",
    "            for j in range(k):\n",
    "                if arr[i+j*m:i+(j+1)*m]==tem:\n",
    "                    a+=1\n",
    "            if a==k:\n",
    "                return True\n",
    "                break\n",
    "            if i==len(arr)-1:\n",
    "                return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        arr2=''\n",
    "        for i in arr:\n",
    "            arr2+=chr(i)\n",
    "        for i in range(len(arr)-m):\n",
    "            if arr2[i:i+m]*k in arr2:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "from typing import List\n",
    "\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        for i in range(n):\n",
    "            pattern = arr[i:i+m] * k\n",
    "            # print(f\"l={i},r={i+m*k},pattern={pattern}\")\n",
    "            if i + m * k > n:\n",
    "                return False\n",
    "            if arr[i:i+m*k] == pattern:\n",
    "                return True\n",
    "        return False\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for i in range(0,len(arr)-m*k+1):\n",
    "            if self.issublist(arr[i:i+m]*k,arr):\n",
    "                return True\n",
    "        return False\n",
    "    \n",
    "    def issublist(self,list_child, list_parent):\n",
    "        for i in range(0, len(list_parent) - len(list_child)+1):\n",
    "            if list_child == list_parent[i:i + len(list_child)]:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        cur = 0\n",
    "        for i in range(n):\n",
    "            if i - m >= 0 and arr[i] == arr[i - m]:\n",
    "                cur += 1\n",
    "                if cur >= m * (k - 1):\n",
    "                    return True\n",
    "            else:\n",
    "                cur = 0\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        \n",
    "        a = len(arr)\n",
    "        for i in range(a - m * k + 1):  # 从头开始，确保有足够的空间来检查模式\n",
    "            count = 0\n",
    "            for j in range(i + m, a, m):  # 使用步长为 m，但是每次都从下一个元素开始比较\n",
    "                if arr[i:i + m] == arr[j:j + m]:  # 比较是否有 m 长的连续子数组重复\n",
    "                    count += 1\n",
    "                    if count == k - 1:  # 因为我们从第一个模式开始计数，所以需要 k-1 个重复模式\n",
    "                        return True\n",
    "                else:\n",
    "                    break  # 如果连续的子数组不匹配，立即中断内层循环\n",
    "        return False  # 所有可能的起点都没有找到合适的模式\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        for l in range(n - m * k + 1):\n",
    "            offset = 0\n",
    "            while offset < m * k:\n",
    "                if arr[l + offset] != arr[l + offset % m]:\n",
    "                    break\n",
    "                offset += 1\n",
    "            if offset == m * k:\n",
    "                return True\n",
    "        return False\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        while len(arr)>=m*k:\n",
    "            for i in range(k-1):\n",
    "                if not arr[i*m:(i+1)*m]==arr[(i+1)*m:(i+2)*m]:\n",
    "                    break\n",
    "            else:\n",
    "                return True\n",
    "            arr=arr[1:]\n",
    "        return False\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n=len(arr)\n",
    "        if n<m*k:\n",
    "            return False\n",
    "        res=n-m*k\n",
    "        for i in range(res+1):\n",
    "            top=m-1\n",
    "            low=0\n",
    "            count=0\n",
    "            while top<len(arr):\n",
    "                if arr[0:m]==arr[low:top+1]:\n",
    "                    count+=1\n",
    "                    low=top+1\n",
    "                    top=low+m-1       \n",
    "                else:\n",
    "                    break\n",
    "                if count==k:\n",
    "                    return True\n",
    "            arr.pop(0)\n",
    "            print(count)\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for i in range(len(arr) - m * k + 1):\n",
    "            if arr[i: i + m] * k == arr[i: i + m * k]:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        for i in range(n - m * k + 1):\n",
    "            temp = arr[i: i + m]\n",
    "            cnts = 0\n",
    "            for j in range(k):\n",
    "                left, right =  i + (j+1) * m, i + (j + 2) * m\n",
    "                temp1 = arr[left : right]\n",
    "                if temp != temp1:\n",
    "                    break\n",
    "                cnts += 1\n",
    "            if cnts + 1 >= k:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for i, x in enumerate(arr[:- m * k + 1]):\n",
    "            if arr[i:i+m*k] == arr[i:i + m] * k:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        cur = 0\n",
    "        target = m * k - m\n",
    "        for i in range(m, n):\n",
    "            if arr[i] == arr[i - m]:\n",
    "                cur += 1\n",
    "                if cur >= target:\n",
    "                    return True\n",
    "            else:\n",
    "                cur = 0\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        if m * k > n: \n",
    "            return False \n",
    "        cnt = 0\n",
    "        \n",
    "        for i in range(n - m * k + 1):\n",
    "            cnt, pos = 1, i \n",
    "            while arr[pos : pos+m] == arr[pos+m : pos+m*2]: \n",
    "                cnt += 1\n",
    "                if cnt == k: \n",
    "                    return True\n",
    "                pos += m\n",
    "\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for start in range(len(arr)):\n",
    "            if start+m*k<=len(arr):\n",
    "                if arr[start:start+m]*k==arr[start:start+m*k]:\n",
    "                    return True\n",
    "        return False\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:  \n",
    "        return any(arr[i:i+m]*k==arr[i:i+m*k] for i in range(len(arr)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr); seen = set()\n",
    "        for i in range(n - m*k + 1):\n",
    "            tem = arr[i:i+m] * k\n",
    "            # if tem in seen:continue\n",
    "            # seen.add(tem)\n",
    "            if tem in [arr[ii:ii+m*k] for ii in range(i,n - m*k + 1)]:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for i in range(len(arr)-1):\n",
    "            lst = arr[i:i+m]\n",
    "            if lst*k == arr[i:i+m*k]:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        return any(arr[i:i+m] * k == arr[i:i + m * k] for i in range(0, len(arr)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for j in range(len(arr)):\n",
    "            model = arr[j:j+m]\n",
    "            count=1\n",
    "            for z in range(j+m,len(arr),+m):\n",
    "                new = arr[z:z+m]             \n",
    "                if model==new:\n",
    "                    count+=1\n",
    "                    if count == k:\n",
    "                        return True\n",
    "                else:\n",
    "                    break\n",
    "        return False\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for start in range(len(arr)):\n",
    "            if start+m*k<=len(arr):\n",
    "                if arr[start:start+m]*k==arr[start:start+m*k]:\n",
    "                    return True\n",
    "        return False\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        for start in range(len(arr)):\n",
    "            if start+m*k<=len(arr):\n",
    "                if arr[start:start+m]*k==arr[start:start+m*k]:\n",
    "                    return True\n",
    "        return False\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        for l in range(n - m * k + 1):\n",
    "            offset = 0\n",
    "            while offset < m * k:\n",
    "                if arr[l + offset] != arr[l + offset % m]:\n",
    "                    break\n",
    "                offset += 1\n",
    "            if offset == m * k:\n",
    "                return True\n",
    "        return False\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "       s=len(arr)\n",
    "       for i in range(s-m*k+1):\n",
    "           a=0\n",
    "           while a<m*k:\n",
    "               if arr[i+a]!=arr[i+a%m]:\n",
    "                   break\n",
    "               a+=1\n",
    "           if a==m*k:\n",
    "                return True\n",
    "       return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        \n",
    "        i = 0\n",
    "        j = 0\n",
    "        while i<=n-m:\n",
    "            if arr[i:i+m]!=arr[i-m:i]:\n",
    "                j = 1\n",
    "                i += 1\n",
    "            else:\n",
    "                j+=1\n",
    "                i+=m\n",
    "                if j == k:\n",
    "                    return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        # 寻找连续，如果出错，模式变为指针向后移动m-1格到指针位置的数字\n",
    "        ptn = arr[:m]\n",
    "        cur_p = 0\n",
    "        success = m\n",
    "        for i in range(m, len(arr)):\n",
    "            # 一个数匹配成功\n",
    "            if arr[i] == ptn[cur_p]:\n",
    "                cur_p = (cur_p + 1) % m\n",
    "                success += 1\n",
    "                if success // m == k:\n",
    "                    return True\n",
    "            else:\n",
    "                success = m\n",
    "                ptn = arr[i - m + 1:i + 1]\n",
    "                cur_p = 0\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "  def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "    n = len(arr)\n",
    "    if n < m*k: return False\n",
    "    for i in range(n-m*k+1):\n",
    "      if arr[i:m*k+i] == arr[i:m+i]*k:\n",
    "        return True\n",
    "    return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        for l in range(n - m * k + 1):\n",
    "            offset = 0\n",
    "            while offset < m * k:\n",
    "                if arr[l + offset] != arr[l + offset % m]:\n",
    "                    break\n",
    "                offset += 1\n",
    "            if offset == m * k:\n",
    "                return True\n",
    "        return False\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        # 寻找连续，如果出错，模式变为指针向后移动m-1格到指针位置的数字\n",
    "        ptn = 0\n",
    "        ptn_offset = 0\n",
    "        cur_p = 0\n",
    "        success = m\n",
    "        for i in range(m, len(arr)):\n",
    "            # 一个数匹配成功\n",
    "            if arr[i] == arr[ptn + ptn_offset]:\n",
    "                ptn_offset = (ptn_offset + 1) % m\n",
    "                success += 1\n",
    "                if success // m == k:\n",
    "                    return True\n",
    "            else:\n",
    "                success = m\n",
    "                ptn = i - m + 1\n",
    "                ptn_offset = 0\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n = len(arr)\n",
    "        for i in range(n - m * k + 1):\n",
    "            s = 0\n",
    "            while s < m * k:\n",
    "                if arr[i + s] != arr[i + s % m]:\n",
    "                    break\n",
    "                s += 1\n",
    "            if s == m * k:\n",
    "                return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n=len(arr)\n",
    "        for i in range(n-m+1):\n",
    "            if arr[i:i+m]*k==arr[i:i+m*k]:\n",
    "                return True   \n",
    "        return False \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def containsPattern(self, arr: List[int], m: int, k: int) -> bool:\n",
    "        n=len(arr)\n",
    "        for l in range(0,n-m*k+1):\n",
    "            offset=0\n",
    "            while offset<m*k:\n",
    "                if arr[l+offset]!=arr[l+offset%m]:\n",
    "                    break\n",
    "                offset+=1\n",
    "            if offset==m*k:\n",
    "                return True\n",
    "        return False"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
